package com.example.demo.common.response;



import java.util.ArrayList;
import java.util.List;

public class ServiceResponse{

	private String desc;
	private Integer code;
	private String origin_request_id;
	private String response_time;
	private Long total;

	public Long getTotal() {
		return total;
	}

	public void setTotal(Long total) {
		this.total = total;
	}

	private List<ServiceError> errors;

	public List<ServiceError> getErrors() {
		return errors;
	}

	public void setErrors(List<ServiceError> errors) {
		this.errors = errors;
	}
	
	public String getOrigin_request_id() {
		return origin_request_id;
	}

	public void setOrigin_request_id(String origin_request_id) {
		this.origin_request_id = origin_request_id;
	}

	public String getResponse_time() {
		return response_time;
	}

	public void setResponse_time(String response_time) {
		this.response_time = response_time;
	}


	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}
	
	public void addError(ServiceError error) {
		if(this.errors==null){
			this.errors=new ArrayList<ServiceError>();
		}
		this.errors.add(error);
	}
	
	public void addError(String code,String desc) {
		ServiceError error=new ServiceError(code,desc);
		this.addError(error);
	}

	@Override
	public String toString(){
		StringBuffer buf=new StringBuffer();
		buf.append("{").append("origin_request_id:"+origin_request_id).append(", response_time:"+response_time).append(",code:"+code).append(",desc:"+desc).append("}");
		return buf.toString();
	}
}
